//package com.codegeek.framework.config;
//
//import org.springframework.beans.factory.annotation.Value;
//
//import javax.servlet.*;
//import javax.servlet.annotation.WebFilter;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
//@WebFilter(urlPatterns = "/*", filterName = "CorsFilter")
//public class CorsFilter implements Filter {
//
//    @Value("${gen.crossUrl}")
//    private String url;
//
//    @Override
//    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
//        HttpServletResponse response = (HttpServletResponse) res;
//        HttpServletRequest reqs = (HttpServletRequest) req;
//        String curOrigin = reqs.getHeader("Origin");
//        System.out.println("filter："+reqs.getSession().getId());
//        response.setHeader("Access-Control-Allow-Origin", url);
//        response.setHeader("Access-Control-Allow-Credentials","true" );
//        response.setHeader("Access-Control-Allow-Methods", "GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, PATCH");
//        response.setHeader("Access-Control-Allow-Headers", "Authorization,token,X-Requested-With, Accept, Content-Type");
//        response.setHeader("Access-Control-Max-Age", "3600");
//        if ("OPTIONS".equalsIgnoreCase(reqs.getMethod())) {
//            response.setStatus(HttpServletResponse.SC_OK);
//        } else {
//        }
//        chain.doFilter(req, res);
//    }
//
//    @Override
//    public void destroy() {}
//
//}
